import './FormOperations.scss'
import { useMount } from 'ahooks'
import PropTypes from 'prop-types'
import { useState, lazy } from 'react'

import { FormAssembly } from '../../Template/FormTemplate'

const LoadSvg = lazy(() => import('../../Views/LoadSvg'))

const FormOperations = ({ data, actionRef, Off }) => {
    FormOperations.propTypes = {
        data: PropTypes.object,
        actionRef: PropTypes.object,
        Off: PropTypes.func
    }
    const [FromParams, setFromParams] = useState()
    useMount(() => { setFromParams(data) })

    return (
        <div className='FormOperations'>
            {FromParams ?
                <FormAssembly
                    {...FromParams}
                    actionRef={actionRef}
                    Off={Off}
                /> :
                < LoadSvg style={{ '--background': 'transparent', '--stroke': '#212121', width: '100%', height: '100%' }} />
            }
        </div>
    );
};

export default FormOperations;